#ifndef BRIDGE_H
#define BRIDGE_H

#include <QObject>

#include "serialport.h"
#include "tcpclient.h"
#include "tcpserver.h"
#include "udp.h"

class Bridge : public QObject
{
    Q_OBJECT
public:
    explicit Bridge(QObject *parent = nullptr);
    bool connectMysql();

    void init();
signals:

public slots:
    // 从网络向串口发送数据
    void UdpToSerial(quint16 localPort, const QHostAddress &senderIp, quint16 senderPort, const QByteArray &data);
    void TcpClientToSerial(int logicalClientPort, const QByteArray &data);
    void TcpServerToSerial(int port, const QByteArray &data);

    // 从串口向网络发送数据
    void SerialToUdp(const QString &ComName, const QByteArray& data);
    void SerialToTcpClient(const QString &ComName, const QByteArray &data);
    void SerialToTcpServer(const QString &ComName, const QByteArray &data);

private:
    SerialPort s;
    Udp u;
    TcpClient tc;
    TCpsever ts;
};

#endif // BRIDGE_H
